package com.grocery.config;

import com.grocery.interceptor.UserLoginInterceptor;
import com.grocery.util.SYS;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class GroceryWebMvcConfig implements WebMvcConfigurer {
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(SYS.FILE_UPLOAD_URL+"/**").addResourceLocations("file:"+SYS.FILE_UPLOAD_DIR);
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserLoginInterceptor()).addPathPatterns("/page/cart","/page/dashboard","/page/editprofile","/page/address","/page/editaddress","/page/addaddress","/page/checkout","/page/products","/page/categoryproducts","/page/password","/page/orders");
    }
}
